package com.chengh.nami.core.security.contextHolder;

import org.springframework.security.core.Authentication;

/**
 * 身份验证信息
 *
 * @author chengh
 */
public class AuthenticationContextHolder {

    /**
     * 共享线程变量
     */
    private static final ThreadLocal<Authentication> contextHolder = new ThreadLocal<>();

    /**
     * 获取信息
     * @return
     */
    public static Authentication getContext() {
        return contextHolder.get();
    }

    /**
     * 设置信息
     * @param context
     */
    public static void setContext(Authentication context) {
        contextHolder.set(context);
    }

    /**
     * 清除信息
     */
    public static void clearContext() {
        contextHolder.remove();
    }
}
